/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * mainscreen2.java
 *
 * Created on Aug 21, 2011, 2:55:36 PM
 */
/**
 *
 * @author Jino
 */
import java.awt.Point;
import java.sql.*;
import javax.swing.table.*;
import javax.swing.table.TableModel.*;
import javax.swing.JTable.*;
import java.sql.ResultSet;
public class mainscreen2 extends javax.swing.JFrame {

    private int jrawr;

    public void eraseRows(DefaultTableModel tmodel)
    {
                        int row = tmodel.getRowCount();
                        while(row > 0)
    {
    row--;
    tmodel.removeRow(row);
    }
    }

    /** Creates new form mainscreen2 */
    public mainscreen2() {

        initComponents();


        DBConnect con = new DBConnect();
        Connection conn = con.connect();
        ResultSet res;
        PreparedStatement pstmt;
        DefaultTableModel tmodel1 = (DefaultTableModel)jTable1.getModel();
        DefaultTableModel tmodel2 = (DefaultTableModel)jTable2.getModel();
        DefaultTableModel tmodel3 = (DefaultTableModel)jTable3.getModel();
        DefaultTableModel tmodel4 = (DefaultTableModel)jTable4.getModel();
        try{
            pstmt = conn.prepareStatement("Select * from dbtable");
            res = pstmt.executeQuery();
            while(res.next()){
                String[] s1 = {res.getString("ProductCode"), res.getString("ProductName"), res.getString("NumStocks"), res.getString("BuyPrice"), res.getString("SellPrice"), res.getString("ExpirationDate")};
                tmodel1.addRow(s1);
                tmodel2.addRow(s1);
                tmodel3.addRow(s1);
                tmodel4.addRow(s1);
            }
        }catch(Exception e){}
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        labelStoreName1 = new javax.swing.JLabel();
        labelStoreBanner1 = new javax.swing.JLabel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        labelProduct1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        textFieldProd1 = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        textFieldAdd1 = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        textFieldExpiry1 = new javax.swing.JTextField();
        buttonUpdate1 = new javax.swing.JButton();
        buttonReset1 = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTable3 = new javax.swing.JTable();
        jLabel9 = new javax.swing.JLabel();
        textFieldProdCode3 = new javax.swing.JTextField();
        textFieldSold3 = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        buttonMod3 = new javax.swing.JButton();
        buttonClear3 = new javax.swing.JButton();
        textFieldPriceSold3 = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTable2 = new javax.swing.JTable();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        textFieldProdCode2 = new javax.swing.JTextField();
        textFieldProdName2 = new javax.swing.JTextField();
        textFieldBuy2 = new javax.swing.JTextField();
        textFieldSell2 = new javax.swing.JTextField();
        textFieldStocks2 = new javax.swing.JTextField();
        textFieldExpiry2 = new javax.swing.JTextField();
        buttonEdit2 = new javax.swing.JButton();
        buttonClear2 = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        jTable4 = new javax.swing.JTable();
        jLabel11 = new javax.swing.JLabel();
        textFieldProdName4 = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        textFieldBuy4 = new javax.swing.JTextField();
        textFieldStocks4 = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        textFieldSell4 = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        textFieldExpiry4 = new javax.swing.JTextField();
        buttonAdd4 = new javax.swing.JButton();
        buttonClear4 = new javax.swing.JButton();
        buttonHelp = new javax.swing.JButton();
        buttonReport = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setResizable(false);

        labelStoreName1.setFont(new java.awt.Font("Tahoma", 1, 24));
        labelStoreName1.setText("De Guzman's Sari-sari Store");

        labelStoreBanner1.setFont(new java.awt.Font("Tahoma", 2, 14));
        labelStoreBanner1.setText("Inventory Tracking System");

        jTabbedPane1.setName(""); // NOI18N

        labelProduct1.setFont(new java.awt.Font("Tahoma", 1, 12));
        labelProduct1.setText("Product Code :");

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Product Code", "Product Name", "Stocks", "Buy Price", "Sell Price", "Expiration Date"
            }
        ));
        jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jTable1MouseReleased(evt);
            }
        });
        jScrollPane1.setViewportView(jTable1);

        textFieldProd1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                textFieldProd1ActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel1.setText("Number of Items Added:");

        textFieldAdd1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                textFieldAdd1ActionPerformed(evt);
            }
        });

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel2.setText("Expiry Date:");

        textFieldExpiry1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                textFieldExpiry1ActionPerformed(evt);
            }
        });

        buttonUpdate1.setText("Update");
        buttonUpdate1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonUpdate1ActionPerformed(evt);
            }
        });

        buttonReset1.setText("Clear");
        buttonReset1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonReset1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 539, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(textFieldAdd1, javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(labelProduct1, javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(textFieldProd1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 154, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                            .addComponent(buttonUpdate1)
                            .addGap(21, 21, 21)
                            .addComponent(buttonReset1, 0, 0, Short.MAX_VALUE))
                        .addComponent(textFieldExpiry1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(65, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 470, Short.MAX_VALUE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(labelProduct1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textFieldProd1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textFieldAdd1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textFieldExpiry1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(72, 72, 72)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(buttonUpdate1)
                            .addComponent(buttonReset1))))
                .addContainerGap())
        );

        jTabbedPane1.addTab("Restock Inventory", jPanel1);

        jTable3.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Product Code", "Product Name", "Stocks", "Buy Price", "Sell Price", "Expiration Date"
            }
        ));
        jTable3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jTable3MouseReleased(evt);
            }
        });
        jScrollPane3.setViewportView(jTable3);

        jLabel9.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel9.setText("Product Code:");

        jLabel10.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel10.setText("Items Sold:");

        buttonMod3.setText("Modify");
        buttonMod3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonMod3ActionPerformed(evt);
            }
        });

        buttonClear3.setText("Clear");
        buttonClear3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonClear3ActionPerformed(evt);
            }
        });

        jLabel16.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel16.setText("Price Sold:");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 539, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(textFieldSold3)
                    .addComponent(textFieldProdCode3)
                    .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(textFieldPriceSold3)
                    .addComponent(jLabel16, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(buttonMod3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(buttonClear3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(132, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textFieldProdCode3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel10)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textFieldSold3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel16)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textFieldPriceSold3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(buttonMod3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(buttonClear3))
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 470, Short.MAX_VALUE))
                .addContainerGap())
        );

        jTabbedPane1.addTab("Sales", jPanel3);

        jTable2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Product Code", "Product Name", "Stocks", "Buy Price", "Sell Price", "Expiration Date"
            }
        ));
        jTable2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jTable2MouseReleased(evt);
            }
        });
        jScrollPane2.setViewportView(jTable2);

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel3.setText("Product Code:");

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel4.setText("Product Name:");

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel5.setText("Number of Stocks:");

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel6.setText("Buy Price:");

        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel7.setText("Sell Price:");

        jLabel8.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel8.setText("Expiration Date:");

        buttonEdit2.setText("Edit");
        buttonEdit2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonEdit2ActionPerformed(evt);
            }
        });

        buttonClear2.setText("Clear");
        buttonClear2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonClear2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 539, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jLabel7)
                        .addComponent(textFieldSell2)
                        .addComponent(textFieldBuy2)
                        .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(textFieldProdName2)
                        .addComponent(textFieldProdCode2)
                        .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(textFieldStocks2)
                        .addComponent(textFieldExpiry2)
                        .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(buttonEdit2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(buttonClear2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap(107, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textFieldProdCode2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textFieldProdName2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textFieldBuy2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textFieldSell2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textFieldStocks2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textFieldExpiry2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(35, 35, 35)
                        .addComponent(buttonEdit2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(buttonClear2))
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 470, Short.MAX_VALUE))
                .addContainerGap())
        );

        jTabbedPane1.addTab("Edit", jPanel2);

        jTable4.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Product Code", "Product Name", "Stocks", "Buy Price", "Sell Price", "Expiration Date"
            }
        ));
        jTable4.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jTable4MouseReleased(evt);
            }
        });
        jScrollPane4.setViewportView(jTable4);

        jLabel11.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel11.setText("Product Name:");

        jLabel12.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel12.setText("Buy Price:");

        jLabel13.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel13.setText("Number of Stocks");

        jLabel14.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel14.setText("Sell Price:");

        jLabel15.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel15.setText("Expiration Date:");

        buttonAdd4.setText("Add");
        buttonAdd4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonAdd4ActionPerformed(evt);
            }
        });

        buttonClear4.setText("Clear");
        buttonClear4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonClear4ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 539, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(textFieldProdName4)
                        .addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(textFieldBuy4)
                        .addComponent(textFieldStocks4)
                        .addComponent(jLabel13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(textFieldSell4)
                        .addComponent(jLabel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel15)
                        .addComponent(textFieldExpiry4))
                    .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(buttonAdd4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(buttonClear4, javax.swing.GroupLayout.Alignment.LEADING)))
                .addContainerGap(111, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textFieldProdName4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel12)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textFieldBuy4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel14)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textFieldSell4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel13)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textFieldStocks4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel15)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textFieldExpiry4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(buttonAdd4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(buttonClear4))
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 470, Short.MAX_VALUE))
                .addContainerGap())
        );

        jTabbedPane1.addTab("Add", jPanel4);

        buttonHelp.setText("HELP");

        buttonReport.setText("Generate Report");
        buttonReport.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonReportActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(labelStoreName1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 233, Short.MAX_VALUE)
                        .addComponent(buttonReport)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(buttonHelp)
                        .addGap(34, 34, 34))
                    .addComponent(labelStoreBanner1, javax.swing.GroupLayout.PREFERRED_SIZE, 182, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 780, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(buttonReport)
                        .addComponent(buttonHelp))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(labelStoreName1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(labelStoreBanner1)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 520, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void textFieldExpiry1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textFieldExpiry1ActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_textFieldExpiry1ActionPerformed

    private void textFieldAdd1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textFieldAdd1ActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_textFieldAdd1ActionPerformed

    private void textFieldProd1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textFieldProd1ActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_textFieldProd1ActionPerformed

    private void buttonEdit2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonEdit2ActionPerformed
        // TODO add your handling code here:
         System.out.println(textFieldProdName2.getText());
           DefaultTableModel tmodel1, tmodel2, tmodel3, tmodel4;
           tmodel1 = (DefaultTableModel)jTable1.getModel();
           tmodel2 = (DefaultTableModel)jTable2.getModel();
           tmodel3 = (DefaultTableModel)jTable3.getModel();
           tmodel4= (DefaultTableModel)jTable4.getModel();



           String[] a1 = {textFieldProdName2.getText(), textFieldStocks2.getText(), textFieldBuy2.getText(), textFieldSell2.getText(), textFieldExpiry2.getText()};

           tmodel1.addRow(a1);
           tmodel2.addRow(a1);
           tmodel3.addRow(a1);
           tmodel4.addRow(a1);

           DBConnect conn = new DBConnect();
           Connection connect = conn.connect();
           try{
               PreparedStatement pstmt = connect.prepareStatement("UPDATE dbtable set ProductName=?, Numstocks=?, BuyPrice=?, SellPrice=?, ExpirationDate=? where ProductCode=?");
               pstmt.setString(1, textFieldProdName2.getText());
               pstmt.setInt(2, Integer.parseInt(textFieldStocks2.getText()));
               pstmt.setFloat(3, Float.parseFloat(textFieldBuy2.getText()));
               pstmt.setFloat(4, Float.parseFloat(textFieldSell2.getText()));
               pstmt.setString(5, textFieldExpiry2.getText());
               pstmt.setInt(6, Integer.parseInt(textFieldProdCode2.getText()));
               pstmt.executeUpdate();

               ResultSet res;
/*
        DefaultTableModel tmodel1 = (DefaultTableModel)jTable1.getModel();
        DefaultTableModel tmodel2 = (DefaultTableModel)jTable2.getModel();
        DefaultTableModel tmodel3 = (DefaultTableModel)jTable3.getModel();
*/

           eraseRows(tmodel1);
           eraseRows(tmodel2);
           eraseRows(tmodel3);
           eraseRows(tmodel4);
           

        pstmt = connect.prepareStatement("Select * from dbtable");
            res = pstmt.executeQuery();
            while(res.next()){
                String[] s1 = {res.getString("ProductCode"), res.getString("ProductName"), res.getString("NumStocks"), res.getString("BuyPrice"), res.getString("SellPrice"), res.getString("ExpirationDate")};
                tmodel1.addRow(s1);
                tmodel2.addRow(s1);
                tmodel3.addRow(s1);
                tmodel4.addRow(s1);
            }




               conn.close();
           }catch(Exception e){}

           

           
    }//GEN-LAST:event_buttonEdit2ActionPerformed

    private void buttonAdd4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAdd4ActionPerformed
        // TODO add your handling code here:
         System.out.println(textFieldProdName2.getText());
           DefaultTableModel tmodel1, tmodel2, tmodel3, tmodel4;
           tmodel1 = (DefaultTableModel)jTable1.getModel();
           tmodel2 = (DefaultTableModel)jTable2.getModel();
           tmodel3 = (DefaultTableModel)jTable3.getModel();
           tmodel4 = (DefaultTableModel)jTable4.getModel();
           String[] a1 = {textFieldProdName4.getText(), textFieldStocks4.getText(), textFieldBuy4.getText(), textFieldSell4.getText(), textFieldExpiry4.getText()};

           tmodel1.addRow(a1);
           tmodel2.addRow(a1);
           tmodel3.addRow(a1);
           tmodel4.addRow(a1);

           DBConnect conn = new DBConnect();
           Connection connect = conn.connect();
           try{
               PreparedStatement pstmt = connect.prepareStatement("INSERT INTO dbtable (ProductName, NumStocks, BuyPrice, SellPrice, ExpirationDate) VALUES(?,?,?,?,?)");
               pstmt.setString(1, textFieldProdName4.getText());
               pstmt.setInt(2, Integer.parseInt(textFieldStocks4.getText()));
               pstmt.setFloat(3, Float.parseFloat(textFieldBuy4.getText()));
               pstmt.setFloat(4, Float.parseFloat(textFieldSell4.getText()));
               pstmt.setString(5, textFieldExpiry4.getText());
               pstmt.executeUpdate();

               conn.close();
           }catch(Exception e){}



           eraseRows(tmodel1);
           eraseRows(tmodel2);
           eraseRows(tmodel3);
           eraseRows(tmodel4);



        DBConnect con = new DBConnect();
        Connection conn2 = con.connect();

           ResultSet res;
           PreparedStatement pstmt;
        try{
            pstmt = conn2.prepareStatement("Select * from dbtable");
            res = pstmt.executeQuery();
            while(res.next()){
                String[] s1 = {res.getString("ProductCode"), res.getString("ProductName"), res.getString("NumStocks"), res.getString("BuyPrice"), res.getString("SellPrice"), res.getString("ExpirationDate")};
                tmodel1.addRow(s1);
                tmodel2.addRow(s1);
                tmodel3.addRow(s1);
                tmodel4.addRow(s1);
            }
        }catch(Exception e){}

    }//GEN-LAST:event_buttonAdd4ActionPerformed

    private void buttonClear4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonClear4ActionPerformed
        // TODO add your handling code here:
        textFieldProdName4.setText("");
        textFieldStocks4.setText("");
        textFieldBuy4.setText("");
        textFieldSell4.setText("");
        textFieldExpiry4.setText("");
    }//GEN-LAST:event_buttonClear4ActionPerformed

    private void buttonReset1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonReset1ActionPerformed
        // TODO add your handling code here:
        textFieldProd1.setText("");
        textFieldAdd1.setText("");
        textFieldExpiry1.setText("");
    }//GEN-LAST:event_buttonReset1ActionPerformed

    private void buttonClear2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonClear2ActionPerformed
        // TODO add your handling code here:
        textFieldProdCode2.setText("");
        textFieldProdName2.setText("");
        textFieldStocks2.setText("");
        textFieldBuy2.setText("");
        textFieldSell2.setText("");
        textFieldExpiry2.setText("");

    }//GEN-LAST:event_buttonClear2ActionPerformed

    private void buttonClear3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonClear3ActionPerformed
        // TODO add your handling code here:
        textFieldProdCode3.setText("");
        textFieldSold3.setText("");
    }//GEN-LAST:event_buttonClear3ActionPerformed

    private void buttonMod3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonMod3ActionPerformed
        // TODO add your handling code here:




           System.out.println(textFieldProdName2.getText());
           DefaultTableModel tmodel1, tmodel2, tmodel3, tmodel4;
           tmodel1 = (DefaultTableModel)jTable1.getModel();
           tmodel2 = (DefaultTableModel)jTable2.getModel();
           tmodel3 = (DefaultTableModel)jTable3.getModel();
           tmodel4 = (DefaultTableModel)jTable4.getModel();



           String[] a1 = {textFieldProdName2.getText(), textFieldStocks2.getText(), textFieldBuy2.getText(), textFieldSell2.getText(), textFieldExpiry2.getText()};

           tmodel1.addRow(a1);
           tmodel2.addRow(a1);
           tmodel3.addRow(a1);
           tmodel4.addRow(a1);

           DBConnect conn = new DBConnect();
           Connection connect = conn.connect();
           try{

               PreparedStatement pstmt = connect.prepareStatement("update dbtable set NumStocks=(select NumStocks from (select NumStocks from dbtable where ProductCode=?) as x)-? where ProductCode=? ");
               pstmt.setInt(1, Integer.parseInt(textFieldProdCode3.getText()));
               pstmt.setInt(2, Integer.parseInt(textFieldSold3.getText()));
               pstmt.setInt(3, Integer.parseInt(textFieldProdCode3.getText()));
             
               pstmt.executeUpdate();



               
           }catch(Exception e){}

           try{

               PreparedStatement pstmt = connect.prepareStatement("insert into report (ProductCode,ProductName,ItemsSold,PriceSold) Values (?,(select ProductName from dbtable where ProductCode=?),?,?)");
               pstmt.setInt(1, Integer.parseInt(textFieldProdCode3.getText()));
               pstmt.setInt(2, Integer.parseInt(textFieldProdCode3.getText()));
               pstmt.setInt(3, Integer.parseInt(textFieldSold3.getText()));
               pstmt.setFloat(4, Float.parseFloat(textFieldPriceSold3.getText()));

               pstmt.executeUpdate();



               conn.close();
           }catch(Exception e){}

           eraseRows(tmodel1);
           eraseRows(tmodel2);
           eraseRows(tmodel3);
           eraseRows(tmodel4);


           DBConnect con = new DBConnect();
        Connection conn2 = con.connect();

           ResultSet res;
           PreparedStatement pstmt;
        try{
            pstmt = conn2.prepareStatement("Select * from dbtable");
            res = pstmt.executeQuery();
            while(res.next()){
                String[] s1 = {res.getString("ProductCode"), res.getString("ProductName"), res.getString("NumStocks"), res.getString("BuyPrice"), res.getString("SellPrice"), res.getString("ExpirationDate")};
                tmodel1.addRow(s1);
                tmodel2.addRow(s1);
                tmodel3.addRow(s1);
                tmodel4.addRow(s1);
            }
        }catch(Exception e){}













       /*

           DBConnect con2 = new DBConnect();
        Connection conn3 = con2.connect();

           
        try{
            PreparedStatement pstmt = connect.prepareStatement("update report set ItemsSold=(select ItemsSold from (select ItemsSold from results where ProductCode=?) as x)-? where ProductCode=? ");
               pstmt.setInt(1, Integer.parseInt(textFieldProdCode3.getText()));
               pstmt.setInt(2, Integer.parseInt(textFieldSold3.getText()));
               pstmt.setInt(3, Integer.parseInt(textFieldProdCode3.getText()));

               pstmt.executeUpdate();



               conn.close();
            }
        }catch(Exception e){}


           */

    }//GEN-LAST:event_buttonMod3ActionPerformed

    private void buttonUpdate1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonUpdate1ActionPerformed
        // TODO add your handling code here:
        System.out.println(textFieldProdName2.getText());
           DefaultTableModel tmodel1, tmodel2, tmodel3, tmodel4;
           tmodel1 = (DefaultTableModel)jTable1.getModel();
           tmodel2 = (DefaultTableModel)jTable2.getModel();
           tmodel3 = (DefaultTableModel)jTable3.getModel();
           tmodel4 = (DefaultTableModel)jTable4.getModel();


           String[] a1 = {textFieldProdName2.getText(), textFieldStocks2.getText(), textFieldBuy2.getText(), textFieldSell2.getText(), textFieldExpiry2.getText()};

           tmodel1.addRow(a1);
           tmodel2.addRow(a1);
           tmodel3.addRow(a1);
           tmodel4.addRow(a1);

           DBConnect conn = new DBConnect();
           Connection connect = conn.connect();
           try{

               PreparedStatement pstmt = connect.prepareStatement("update dbtable set NumStocks=(select NumStocks from (select NumStocks from dbtable where ProductCode=?) as x)+?, ExpirationDate=? where ProductCode=? ");
               pstmt.setInt(1, Integer.parseInt(textFieldProd1.getText()));
               pstmt.setInt(2, Integer.parseInt(textFieldAdd1.getText()));
               pstmt.setString(3, textFieldExpiry1.getText());
               pstmt.setInt(4, Integer.parseInt(textFieldProd1.getText()));

               pstmt.executeUpdate();



               conn.close();
           }catch(Exception e){}

           eraseRows(tmodel1);
           eraseRows(tmodel2);
           eraseRows(tmodel3);
           eraseRows(tmodel4);


           DBConnect con = new DBConnect();
        Connection conn2 = con.connect();

           ResultSet res;
           PreparedStatement pstmt;
        try{
            pstmt = conn2.prepareStatement("Select * from dbtable");
            res = pstmt.executeQuery();
            while(res.next()){
                String[] s1 = {res.getString("ProductCode"), res.getString("ProductName"), res.getString("NumStocks"), res.getString("BuyPrice"), res.getString("SellPrice"), res.getString("ExpirationDate")};
                tmodel1.addRow(s1);
                tmodel2.addRow(s1);
                tmodel3.addRow(s1);
                tmodel4.addRow(s1);
            }
        }catch(Exception e){}


    }//GEN-LAST:event_buttonUpdate1ActionPerformed

    private void jTable1MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseReleased
        // TODO add your handling code here:
        Point p = evt.getPoint();
        int selectedRow = jTable1.rowAtPoint(p);
        textFieldProd1.setText(jTable1.getValueAt(selectedRow, 0).toString());
        //textFieldAdd1.setText(jTable1.getValueAt(selectedRow, 2).toString());
        textFieldExpiry1.setText(jTable1.getValueAt(selectedRow, 5).toString());

    }//GEN-LAST:event_jTable1MouseReleased

    private void jTable3MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable3MouseReleased
        // TODO add your handling code here:
        Point p = evt.getPoint();
        int selectedRow = jTable3.rowAtPoint(p);
        textFieldProdCode3.setText(jTable3.getValueAt(selectedRow, 0).toString());
        textFieldPriceSold3.setText(jTable3.getValueAt(selectedRow, 4).toString());
    }//GEN-LAST:event_jTable3MouseReleased

    private void jTable2MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable2MouseReleased
        // TODO add your handling code here:
        Point p = evt.getPoint();
        int selectedRow = jTable2.rowAtPoint(p);
        textFieldProdCode2.setText(jTable2.getValueAt(selectedRow, 0).toString());
        textFieldProdName2.setText(jTable2.getValueAt(selectedRow, 1).toString());
        textFieldStocks2.setText(jTable2.getValueAt(selectedRow, 2).toString());
        textFieldBuy2.setText(jTable2.getValueAt(selectedRow, 3).toString());
        textFieldSell2.setText(jTable2.getValueAt(selectedRow, 4).toString());
        
        textFieldExpiry2       .setText(jTable2.getValueAt(selectedRow, 5).toString());
}//GEN-LAST:event_jTable2MouseReleased

    private void jTable4MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable4MouseReleased
        // TODO add your handling code here:
        
    }//GEN-LAST:event_jTable4MouseReleased

    private void buttonReportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonReportActionPerformed
        // TODO add your handling code here:
       System.out.println(textFieldProdName2.getText());
           DefaultTableModel tmodel1, tmodel2, tmodel3, tmodel4;
           tmodel1 = (DefaultTableModel)jTable1.getModel();
           tmodel2 = (DefaultTableModel)jTable2.getModel();
           tmodel3 = (DefaultTableModel)jTable3.getModel();
           tmodel4 = (DefaultTableModel)jTable4.getModel();


           String[] a1 = {textFieldProdName2.getText(), textFieldStocks2.getText(), textFieldBuy2.getText(), textFieldSell2.getText(), textFieldExpiry2.getText()};
           /*
           tmodel1.addRow(a1);
           tmodel2.addRow(a1);
           tmodel3.addRow(a1);
           tmodel4.addRow(a1);
           */
           DBConnect conn = new DBConnect();
           Connection connect = conn.connect();
           try{

               PreparedStatement pstmt = connect.prepareStatement("delete from report");
              

               pstmt.executeUpdate();



               conn.close();
           }catch(Exception e){}



        
    }//GEN-LAST:event_buttonReportActionPerformed


    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                mainscreen2 main1 = new mainscreen2();
                main1.setVisible(true);
                main1.setLocationRelativeTo(null);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton buttonAdd4;
    private javax.swing.JButton buttonClear2;
    private javax.swing.JButton buttonClear3;
    private javax.swing.JButton buttonClear4;
    private javax.swing.JButton buttonEdit2;
    private javax.swing.JButton buttonHelp;
    private javax.swing.JButton buttonMod3;
    private javax.swing.JButton buttonReport;
    private javax.swing.JButton buttonReset1;
    private javax.swing.JButton buttonUpdate1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JTable jTable2;
    private javax.swing.JTable jTable3;
    private javax.swing.JTable jTable4;
    private javax.swing.JLabel labelProduct1;
    private javax.swing.JLabel labelStoreBanner1;
    private javax.swing.JLabel labelStoreName1;
    private javax.swing.JTextField textFieldAdd1;
    private javax.swing.JTextField textFieldBuy2;
    private javax.swing.JTextField textFieldBuy4;
    private javax.swing.JTextField textFieldExpiry1;
    private javax.swing.JTextField textFieldExpiry2;
    private javax.swing.JTextField textFieldExpiry4;
    private javax.swing.JTextField textFieldPriceSold3;
    private javax.swing.JTextField textFieldProd1;
    private javax.swing.JTextField textFieldProdCode2;
    private javax.swing.JTextField textFieldProdCode3;
    private javax.swing.JTextField textFieldProdName2;
    private javax.swing.JTextField textFieldProdName4;
    private javax.swing.JTextField textFieldSell2;
    private javax.swing.JTextField textFieldSell4;
    private javax.swing.JTextField textFieldSold3;
    private javax.swing.JTextField textFieldStocks2;
    private javax.swing.JTextField textFieldStocks4;
    // End of variables declaration//GEN-END:variables
}
